<?php

/**
 * InsStage form.
 *
 * @package    tfe
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class InsStageForm extends BaseInsStageForm {
    public function configure() {

        unset($this['annee'], $this['created_at'], $this['updated_at'], $this['deleted_at']);


        $this->widgetSchema['id_contact']->setOption('renderer_class', 'sfWidgetFormDoctrineJQueryAutocompleter');
        $this->widgetSchema['id_contact']->setOption('renderer_options', array(
                'model' => 'Contact',
                'url'   => '/contact/autocomplete',
        ));

        $this->widgetSchema['id_groupe']->setOption('renderer_class', 'sfWidgetFormDoctrineJQueryAutocompleter');
        $this->widgetSchema['id_groupe']->setOption('renderer_options', array(
                'model' => 'Groupe',
                'url'   => '/groupe/autocomplete',
        ));

        $this->widgetSchema['parent']->setOption('renderer_class', 'sfWidgetFormDoctrineJQueryAutocompleter');
        $this->widgetSchema['parent']->setOption('renderer_options', array(
                'model' => 'Contact',
                'url'   => '/contact/autocomplete',
        ));

        $this->widgetSchema['id_stage']->setOption('renderer_class', 'sfWidgetFormDoctrineJQueryAutocompleter');
        $this->widgetSchema['id_stage']->setOption('renderer_options', array(
                'model' => 'Stage',
                'url'   => '/stage/autocomplete',
        ));

        $dateWidget = new sfWidgetFormI18nDate(array(
                        'format' => '%day%/%month%/%year%',
                        'culture'=>'fr'
        ));
        $this->widgetSchema['date_de_paiement'] = new sfWidgetFormJqueryDate(array(
                        'date_widget' => $dateWidget,
                        'culture'=>'fr_FR'
        ));


        // check des champs contact et groupe
        // voir la méthode verifierContactOuGroupe() dans InscriptionForm
        $v = new sfValidatorCallback(array(
                        'callback' => array($this, 'verifierContactOuGroupe'),) ,
                array('invalid'  => 'Veuillez choisir un contact OU un groupe.'));

        $this->validatorSchema->setPostValidator($v);
    }
}
